package apis

import (
	"github.com/gin-gonic/gin"
	"goWebTest/goGinWebTest/common/result"
	"goWebTest/goGinWebTest/models"
	"goWebTest/goGinWebTest/service"
	"net/http"
)

type UserAPI struct {
	Api
}

// GetPage
// @Summary 列表用户信息数据
// @Description 获取JSON
// @Tags 用户
// @Param username query string false "username"
// @Success 200 {string} {object} models.User "{"code": 200, "data": [...]}"
// @Router /api/user/listUser [get]
// @Security Bearer
func (e UserAPI) ListUser(c *gin.Context) {
	e.MakeContext(c)
	userImpl := service.UserImpl{}
	//userImpl.GormDb = e.Orm
	var list []models.User
	err := userImpl.GetList(&list)
	if err != nil {
		e.Logger.Error(500, err, "查询失败")
		return
	}
	e.Context.JSON(http.StatusOK, result.ResultSuccessData(list))
}
